<template>
  <div class="app-container" ref="myPhotoDiv">
    <el-tabs
      v-model="currentTab"
      type="card"
      class="center-tabs"
      @tab-click="tabHandleClick"
    >
      <el-tab-pane label="基本信息" name="baseInfo">
        <span slot="label">
          基本信息
          <el-badge
            v-if="countAngle.visitCount > 0"
            :value="countAngle.visitCount"
            class="tab-content-badge"
          ></el-badge>
        </span>

        <el-row class="base-info-box" v-if="baseInfoData.length > 0">
          <span>姓名:{{ baseInfoData[0].patientName }}</span>
          <span
            >性别:
            <dict-tag
              :options="dict.type.sys_user_sex"
              :value="baseInfoData[0].sex"
              style="display: inline-block"
          /></span>
          <span>出生日期:{{ baseInfoData[0].birthDate }}</span>
          <span> 身份证:{{ baseInfoData[0].idNum }}</span>
        </el-row>
        <el-collapse v-model="activeName" accordion>
          <el-collapse-item
            :title="
              gethospital(item.hospitalName) +
              parseTime(item.createTime) +
              item.doctorDiagnosis
            "
            v-for="(item, index) in baseInfoData"
            :key="index"
            :name="index"
          >
            <el-row class="bigFont">
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >顾客编号:<span class="normalFont">{{
                  item.visitNum
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >顾客ID:<span class="normalFont">{{
                  item.patientId
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >手机:<span class="normalFont">{{
                  item.patientPhone
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >状态:<span class="normalFont">{{
                  matchDict("sys_diagnosis_status", item.status)
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >卡号:<span class="normalFont">{{
                  item.cardNumber
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >顾客分类:<span class="normalFont">{{
                  matchDict("sys_patient_sort", item.customerSort)
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >皮肤色度:<span class="normalFont">{{
                  matchDict("sys_skin_tone", item.tone)
                }}</span></el-col
              >

              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >患者地址:<span class="normalFont">{{
                  item.area
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >详细地址:<span class="normalFont">{{
                  item.address
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >顾客性质:<span class="normalFont">{{
                  matchDict("sys_patient_properties", item.properties)
                }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >职业:<span class="normalFont">{{ item.job }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >微信号:<span class="normalFont">{{ item.wxNum }}</span></el-col
              >
              <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4"
                >登记人:<span class="normalFont">{{
                  item.nickName
                }}</span></el-col
              >

              <el-col :xs="12" :sm="6" :md="6" :lg="4" :xl="4"
                >备注:<span class="normalFont">{{ item.remark }}</span></el-col
              >
            </el-row>
          </el-collapse-item>
        </el-collapse>
      </el-tab-pane>
      <el-tab-pane label="诊前问卷" name="PrediagnosisQuestionnaire">
        <span slot="label">
          诊前问卷
          <el-badge
            v-if="countAngle.formLogCount > 0"
            :value="countAngle.formLogCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="questionForm"
          ref="questionForm"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="questionForm.visitNum"
              placeholder="就诊记录"
              class="selectRed"
              clearable
              @change="getListCustomerForm()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div style="display: flex; overflow-x: auto; margin-bottom: 20px">
          <el-button
            size="medium"
            @click="openQuestionnaire(item, index)"
            v-for="(item, index) in prediagnosisQuestionnaireDataList"
            :key="index"
            :class="isActive == index ? 'yesActive' : ''"
            >{{
              item.visitNum +
              "," +
              parseTime(item.writeTime) +
              "," +
              item.formName
            }}</el-button
          >
        </div>
        <div>
          <formpreview
            v-if="formpreviewContList != null && formBaseStatus"
            :formPreviewList="formpreviewContList"
            :questionFormInfo="questionFormInfo"
            ref="formPreview"
          />
        </div>
      </el-tab-pane>
      <el-tab-pane label="照片" name="pictures">
        <span slot="label">
          照片
          <el-badge
            v-if="countAngle.photoCount > 0"
            :value="countAngle.photoCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-row>
          <el-form
            :model="pictureForm"
            ref="pictureForm"
            size="small"
            :inline="true"
            label-width="78px"
          >
            <el-form-item label="就诊记录" prop="visitNum">
              <el-select
                v-model="pictureForm.visitNum"
                placeholder="就诊记录"
                class="selectRed"
                clearable
                @change="getPhotoList"
              >
                <el-option
                  v-for="item in baseInfoData"
                  :key="item.visitId"
                  :label="
                    gethospital(item.hospitalName) +
                    item.visitNum +
                    getDiagnosisStatusLabel(item.status) +
                    ' ' +
                    item.doctorDiagnosis
                  "
                  :value="item.visitNum"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="拍照设备" prop="type">
              <el-select
                v-model="pictureForm.type"
                placeholder="拍照设备"
                style="width: 120px"
                clearable
                @change="getPhotoList"
              >
                <el-option
                  v-for="dict in dict.type.photo_upload_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="采集日期">
              <el-date-picker
                v-model="dateRange"
                style="width: 240px"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="getPhotoList"
              ></el-date-picker>
            </el-form-item>
            <el-button type="primary" size="mini" @click="getPhotoList"
              >查询</el-button
            >
            <el-button type="primary" size="mini" @click="comparePics"
              >对比显示该顾客照片</el-button
            >
          </el-form>
        </el-row>
        <el-row
          v-for="(item, index) in picData"
          :key="index"
          style="margin-top: 15px"
        >
          <el-row>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span> 顾客编号:{{ item.sysPatientPhotos[0].visitNum }}</span>
            </el-col>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span> 采集日期:{{ item.sysPatientPhotos[0].createTime }}</span>
            </el-col>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span class="flex-span"
                >采集时刻:<dict-tag
                  :options="dict.type.sys_diagnosis_status"
                  :value="item.sysPatientPhotos[0].status"
              /></span>
            </el-col>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span class="flex-span"
                >设备:<dict-tag
                  :options="dict.type.photo_upload_type"
                  :value="item.sysPatientPhotos[0].type"
              /></span>
            </el-col>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span>上传人:{{ item.sysPatientPhotos[0].nickName }}</span>
            </el-col>
            <el-col :xs="24" :sm="6" :md="6" :lg="4" :xl="4">
              <span v-if="item.scoreAiAll" style="color: #1890ff"
                >Ai mMASI总分:{{ item.scoreAiAll.toFixed(1) }}分</span
              >
            </el-col>
          </el-row>
          <el-col :span="24" style="display: flex; flex-wrap: wrap">
            <div
              class="img-txt"
              v-loading="loadingIndex == item.p_index"
              element-loading-text="Ai分析中"
              v-for="(it, Mindex) in item.sysPatientPhotos"
              :key="Mindex"
            >
              <div class="user-info-head">
                <el-image
                  class="img-style"
                  fit="contain"
                  :src="it.thumbnail"
                  @click="watchBigPic(item, Mindex)"
                >
                </el-image>
              </div>
              <span>
                <dict-tag
                  :options="dict.type.photo_lighting_type"
                  :value="it.faceLight"
                />
                <dict-tag
                  :options="dict.type.sys_face_part"
                  :value="it.facePart"
                />
                <div>
                  {{ (it.fileSize / 1024 / 1024).toFixed(2) }}M(压缩质量:{{
                    it.compressionRatio
                  }})
                </div>
                <div v-if="it.scoreAi != null" style="color: #1890ff">
                  Ai mMASI评分:{{ it.scoreAi.toFixed(1) }}分
                </div>
              </span>
              <el-button
                size="mini"
                type="success"
                icon="el-icon-download"
                @click.stop="
                  downLoadphoto(it.photoAddress, it, item.patientName)
                "
                v-if="isAdmin || isUpdate == 1"
                class="downBtn"
                >下载原图</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane label="知情同意书" name="consent">
        <span slot="label">
          知情同意书
          <el-badge
            v-if="countAngle.nformedConsentCount > 0"
            :value="countAngle.nformedConsentCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="consentForm"
          ref="consentForm"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="consentForm.visitNum"
              placeholder="就诊记录"
              class="selectRed w700"
              clearable
              @change="getConsentList()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-row
          v-for="(item, index) in consentDataList"
          :key="index"
          style="margin-top: 15px"
        >
          <el-col :span="24" class="group-info">
            <span>顾客编号:{{ item.sysNformedConsents[0].visitNum }}</span>
          </el-col>
          <el-col :span="24" class="consentBox">
            <div
              v-for="(it, idx) in item.sysNformedConsents"
              :key="idx"
              style="margin-top: 15px"
            >
              <myImg
                class="consentBoxImage"
                :src="baseUrl + it.url"
                :preview-src-list="consentSrcList"
                :myImgIndex="idx"
                @click="getConsentPreviewList(item)"
              >
              </myImg>
              <div class="consentBoxtext">上传人:{{ it.nickName }}</div>
              <div class="consentBoxtext">上传日期:{{ it.createTime }}</div>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane label="温馨提示" name="warmReminder">
        <span slot="label">
          温馨提示
          <el-badge
            v-if="countAngle.tipsCount > 0"
            :value="countAngle.tipsCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="warmReminderRecordParams"
          ref="warmReminderRecordParams"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="warmReminderRecordParams.visitNum"
              placeholder="就诊记录"
              class="selectRed w700"
              clearable
              @change="getWarmReminderRecord()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-table border :data="warmReminderRecordData">
          <el-table-column label="序号" align="center" type="index" width="50">
            <template slot-scope="scope">
              <span>{{ getWarmReminderRecordIndex(scope.$index) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            align="center"
            prop="visitNum"
            label="顾客编号"
            width="160"
          ></el-table-column>
          <el-table-column
            sortable
            align="center"
            prop="title"
            label="文本标题"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            sortable
            align="center"
            prop="selfTips"
            label="个性提示"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            sortable
            align="center"
            prop="nickName"
            label="创建医生"
            width="180"
          ></el-table-column>
          <el-table-column
            sortable
            align="center"
            prop="createTime"
            label="创建日期"
            width="180"
          ></el-table-column>
          <el-table-column
            align="center"
            fixed="right"
            label="操作"
            class-name="small-padding fixed-width"
            width="100"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-document"
                @click="lookRecordItem(scope.row)"
                >查看</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-dialog
          title="温馨提示"
          :visible.sync="warmReminderDialogVisible"
          width="85%"
          center
          :close-on-click-modal="false"
          :append-to-body="true"
          v-dialogDrag
        >
          <div v-html="warmReminderContent.content"></div>
        </el-dialog>
      </el-tab-pane>
      <el-tab-pane label="随访记录" name="followupVisitDataList">
        暂无数据
      </el-tab-pane>
      <el-tab-pane label="诊断和方案" name="diagnosisAndProject">
        <span slot="label">
          诊断和方案
          <el-badge
            v-if="countAngle.doctorCount > 0"
            :value="countAngle.doctorCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="diagnosisQueryParams"
          ref="diagnosisQueryParams"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="diagnosisQueryParams.visitNum"
              placeholder="就诊记录"
              class="selectRed w700"
              clearable
              @change="getDiagnosisAndProject()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-table :data="diagnosisAndProjectDataList" border>
          <el-table-column
            label="序号"
            align="center"
            type="index"
            width="50"
            sortable
          >
            <template slot-scope="scope">
              <span>{{ getIndex(scope.$index) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="顾客编号"
            align="center"
            prop="visitNum"
            sortable
            width="160"
          />
          <el-table-column
            label="顾客姓名"
            align="center"
            prop="patientName"
            width="100"
            :show-overflow-tooltip="true"
            sortable
          />
          <el-table-column
            label="状态"
            align="center"
            prop="status"
            :show-overflow-tooltip="true"
            width="120"
            sortable
          >
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.sys_diagnosis_status"
                :value="scope.row.status"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="诊断方案日期"
            align="center"
            prop="doctorTime"
            width="180"
            sortable
          ></el-table-column>
          <el-table-column
            label="诊断医生"
            align="center"
            prop="doctor"
            sortable
            width="100"
          />
          <el-table-column
            sortable
            label="医生诊断"
            align="left"
            prop="doctorDiagnosis"
            width="220"
          >
            <template slot-scope="scope">
              <span v-html="scope.row.doctorDiagnosis"></span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="医生方案"
            align="center"
            prop="doctorPlan"
            width="220"
          >
            <template slot-scope="scope">
              <el-tooltip placement="top" effect="light">
                <div
                  slot="content"
                  style="
                    max-width: 500px;
                    line-height: 25px;
                    font-size: 16px;
                    background: #fff;
                    padding: 15px;
                    border: 1px solid #eee;
                  "
                >
                  {{ scope.row.doctorPlan }}
                </div>
                <div
                  style="
                    color: #10a1df;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  "
                >
                  {{ scope.row.doctorPlan }}
                </div>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column
            label="咨询方案日期"
            align="center"
            prop="consultationTime"
            width="180"
            sortable
          ></el-table-column>
          <el-table-column
            label="咨询医生"
            align="center"
            prop="consultationer"
            sortable
            width="100"
          />
          <el-table-column
            sortable
            label="咨询诊断"
            align="left"
            prop="consultationDiagnosis"
            width="220"
          >
            <template slot-scope="scope">
              <span v-html="scope.row.consultationDiagnosis"></span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="咨询方案"
            align="center"
            prop="consultationPlan"
            width="220"
          >
            <template slot-scope="scope">
              <el-tooltip placement="top" effect="light">
                <div
                  slot="content"
                  style="
                    max-width: 500px;
                    line-height: 25px;
                    font-size: 16px;
                    background: #fff;
                    padding: 15px;
                    border: 1px solid #eee;
                  "
                >
                  {{ scope.row.consultationPlan }}
                </div>
                <div
                  style="
                    color: #10a1df;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  "
                >
                  {{ scope.row.consultationPlan }}
                </div>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
            width="150"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-document"
                @click="goHistoryDiagnosis(scope.row)"
                >诊断医生历史记录</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="治疗记录" name="treatmentRecord">
        <span slot="label">
          治疗记录
          <el-badge
            v-if="countAngle.treatmentCount > 0"
            :value="countAngle.treatmentCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="treatmentRecordQueryParams"
          ref="treatmentRecordQueryParams"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="treatmentRecordQueryParams.visitNum"
              placeholder="就诊记录"
              class="selectRed w700"
              clearable
              @change="getTreatmentList()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-table
          :data="treatmentRecordDataList"
          show-summary
          :summary-method="getSummaries"
          border
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column
            label="序号"
            align="center"
            type="index"
            width="50"
            sortable
          >
            <template slot-scope="scope">
              <span>{{ getTreatmentRecordIndex(scope.$index) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="顾客编号"
            align="center"
            prop="visitNum"
            sortable
            width="160"
          />
          <el-table-column
            label="顾客姓名"
            align="center"
            prop="patientName"
            :show-overflow-tooltip="true"
            width="100"
            sortable
          />
          <el-table-column
            label="登记日期"
            align="center"
            prop="createTime"
            width="180"
            sortable
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="医生诊断"
            align="center"
            prop="doctorDiagnosis"
            sortable
            width="220"
          />
          <el-table-column
            label="治疗医生"
            align="center"
            prop="treatmentDoctorName"
            sortable
            width="100"
          >
            <template slot-scope="scope">
              <span>{{
                scope.row.treatmentDoctorName
                  ? scope.row.treatmentDoctorName
                  : scope.row.treatmentDoctor
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="状态"
            align="center"
            prop="status"
            :show-overflow-tooltip="true"
            width="120px"
            sortable
          >
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.sys_diagnosis_status"
                :value="scope.row.status"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="治疗项目"
            align="center"
            prop="packageContent"
            sortable
            width="100"
          />
          <el-table-column
            sortable
            label="治疗部位"
            align="center"
            prop="treatmentPlace"
            width="100"
          >
          </el-table-column>
          <el-table-column
            label="治疗次数"
            align="center"
            prop="treatmentTimes"
            sortable
            width="100"
          >
            <template slot-scope="scope">
              <span>1</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="治疗年龄"
            align="center"
            prop="treatmentAge"
            :show-overflow-tooltip="true"
            width="100"
          />
          <el-table-column
            sortable
            label="治疗反应"
            align="center"
            prop="treatmentReaction"
            width="100"
          >
            <template slot-scope="scope">
              <span>{{
                getTreatmentReactionText(scope.row.treatmentReaction)
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="治疗效果"
            align="center"
            prop="treatmentEffect"
            width="100"
          >
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.sys_treatment_effect"
                :value="scope.row.treatmentEffect"
              />
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="治疗日期"
            align="center"
            prop="consultationDate"
            width="155"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.treatmentTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            sortable
            label="治疗价格"
            align="center"
            prop="treatmentPrice"
            width="100"
          />
          <el-table-column
            label="治疗参数"
            align="center"
            prop="remark"
            sortable
            width="220"
          />
        </el-table>
        <pagination
          v-show="treatmentRecordTotal > 0"
          :total="treatmentRecordTotal"
          :page.sync="treatmentRecordQueryParams.pageNum"
          :limit.sync="treatmentRecordQueryParams.pageSize"
          @pagination="getTreatmentList"
        />
      </el-tab-pane>
      <el-tab-pane label="皮肤CT" name="skinct"> 皮肤CT </el-tab-pane>
      <el-tab-pane label="检测指标" name="detectionIndex">
        <span slot="label">
          检测指标
          <el-badge
            v-if="countAngle.visitDetectionCount > 0"
            :value="countAngle.visitDetectionCount"
            class="tab-content-badge"
          ></el-badge>
        </span>
        <el-form
          :model="detectionIndexForm"
          ref="detectionIndexForm"
          size="small"
          :inline="true"
          label-width="78px"
        >
          <el-form-item label="就诊记录" prop="visitNum">
            <el-select
              v-model="detectionIndexForm.visitNum"
              placeholder="就诊记录"
              class="selectRed w700"
              clearable
              @change="getlistDetectionVisit()"
            >
              <el-option
                v-for="item in baseInfoData"
                :key="item.visitId"
                :label="
                  gethospital(item.hospitalName) +
                  item.visitNum +
                  ' ' +
                  parseTime(item.createTime).split(' ')[0] +
                  getDiagnosisStatusLabel(item.status) +
                  ' ' +
                  item.doctorDiagnosis
                "
                :value="item.visitNum"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div>
          <el-table
            border
            v-loading="loading"
            style="width: 100%"
            :data="listDetectionVisit"
          >
            <el-table-column
              label="序号"
              align="center"
              type="index"
              width="50"
            >
              <template slot-scope="scope">
                <span>{{ getDetectionIndexFormIndex(scope.$index) }}</span>
              </template>
            </el-table-column>
            <el-table-column
              label="顾客编号"
              align="center"
              prop="visitNum"
              width="160"
            >
            </el-table-column>
            <el-table-column
              label="顾客姓名"
              align="center"
              prop="patientName"
              :show-overflow-tooltip="true"
              width="100"
            />
            <el-table-column
              label="检测指标"
              align="center"
              prop="visitDetectionName"
            >
            </el-table-column>
            <el-table-column
              label="检测值"
              align="center"
              prop="detectionValue"
              :show-overflow-tooltip="true"
              width="160"
            />
            <el-table-column
              label="异常标志"
              align="center"
              prop="defaultValue"
              :show-overflow-tooltip="true"
              width="120"
            >
              <template slot-scope="scope">
                <span
                  :style="{
                    color: getLabel(scope.row) == '异常' ? 'red' : 'green',
                  }"
                  >{{ getLabel(scope.row) }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              label="正常值"
              align="center"
              prop="defaultValue"
              :show-overflow-tooltip="true"
              width="120"
            >
              <template slot-scope="scope">
                <span
                  v-if="
                    scope.row.hightValue != '' && scope.row.hightValue != null
                  "
                  >{{ scope.row.limitValue }} ~ {{ scope.row.hightValue }}</span
                >
                <span
                  v-else-if="
                    (scope.row.hightValue == '' ||
                      scope.row.hightValue == null) &&
                    scope.row.defaultValue != '' &&
                    scope.row.defaultValue != null
                  "
                  >{{ scope.row.defaultValue }}</span
                >
                <span v-else>-</span>
              </template>
            </el-table-column>

            <el-table-column label="检测医生" align="center" width="100">
              <template slot-scope="scope">
                <span>{{
                  scope.row.nickName ? scope.row.nickName : scope.row.createBy
                }}</span>
              </template>
            </el-table-column>
            <el-table-column
              sortable
              label="检测日期"
              align="center"
              prop="createTime"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime) }}</span>
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="Listtotal > 0"
            :total="Listtotal"
            :page.sync="detectionIndexForm.pageNum"
            :limit.sync="detectionIndexForm.pageSize"
            @pagination="getlistDetectionVisit"
          />
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-dialog
      title="照片比对"
      :visible.sync="comparePicsDialogVisible"
      width="85%"
      center
      :close-on-click-modal="false"
      :append-to-body="true"
      v-dialogDrag
    >
      <comparePics :patientId="basicInfo.patientId"></comparePics>
    </el-dialog>
    <el-dialog
      title="照片标注"
      :visible.sync="picMarkDialogVisible"
      width="100%"
      center
      class="nopaddingBody fullDialog"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <PhotoMark
        :currentUrl="currentUrl"
        :imgList="imgList"
        :myImgIndex="myImgIndex"
        v-if="picMarkDialogVisible"
        @closedEvent="picMarkDialogVisible=false"
        :notSharePageEnter="false"
      >
      </PhotoMark>
    </el-dialog>
    <el-dialog
      title="历史诊断"
      :visible.sync="historyDiagnosisDialogVisible"
      width="85%"
      center
      :close-on-click-modal="false"
      :append-to-body="true"
      v-dialogDrag
    >
      <el-table :data="historyDiagnosisSignalList" border>
        <el-table-column
          label="顾客编号"
          align="center"
          prop="visitNum"
          sortable
          width="160"
        />
        <el-table-column
          label="顾客姓名"
          align="center"
          prop="patientName"
          width="100"
          :show-overflow-tooltip="true"
          sortable
        />
        <el-table-column
          label="诊断方案日期"
          align="center"
          prop="updateTime"
          width="180"
          sortable
        ></el-table-column>
        <el-table-column
          sortable
          label="初复诊"
          align="center"
          prop="returnStatus"
          width="220"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.returnStatus == "0" ? "初诊" : "复诊" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="诊断医生"
          align="center"
          prop="nick_name"
          sortable
          width="100"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.nickName">{{ scope.row.nickName }}</span>
            <span v-else>{{ scope.row.nick_name }}</span>
          </template>
        </el-table-column>
        <el-table-column
          sortable
          label="医生诊断"
          align="left"
          prop="diagnosis"
          width="220"
        >
          <template slot-scope="scope">
            <span v-html="scope.row.diagnosis"></span>
          </template>
        </el-table-column>
        <el-table-column
          sortable
          label="医生方案"
          align="center"
          prop="diagnosisPlan"
        >
          <template slot-scope="scope">
            <el-tooltip placement="top" effect="light">
              <div
                slot="content"
                style="
                  max-width: 500px;
                  line-height: 25px;
                  font-size: 16px;
                  background: #fff;
                  padding: 15px;
                  border: 1px solid #eee;
                "
              >
                {{ scope.row.diagnosisPlan }}
              </div>
              <div
                style="
                  color: #10a1df;
                  overflow: hidden;
                  white-space: nowrap;
                  text-overflow: ellipsis;
                "
              >
                {{ scope.row.diagnosisPlan }}
              </div>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <Screenfull v-show="false" ref="Screenfull"></Screenfull>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { setToken } from "@/utils/auth";
import {
  getVisit,
  listVisitTip,
  getAngleCount,
  getQuestionnaireCommon,
} from "@/api/patientRegistration/registrationList";
import {
  getTreatmentList,
  consentList,
  consentListAll,
  consentUploads,
} from "@/api/treatmentWorkstation/treatmentManagement";
import { addressJson, listPhoto } from "@/api/patients/personal";
import { listPhotos } from "@/api/patients/patient";
import Formpreview from "@/views/system/form/Formpreview";
import myImg from "@/views/components/myImg/myMainImg";
import comparePics from "@/views/photoWorkstation/photoList/comparePics";
import {
  listFormCont,
  listCustomerForm,
  addFormAnswer,
  updateAnswer,
  currencyFormId,
  listForm,
  detailFormAndAnswer,
} from "@/api/system/form";
import PhotoMark from "@/views/components/photoMark/photoMark.vue";
import { listDetectionVisit } from "@/api/photoWorkstation/detection";
import { delPhotoByGroup, startAi } from "@/api/photoWorkstation/photoList";
import { myHistoryDiagnosis } from "@/api/doctorWorkstation/diagnosisList";
import photoUpload from "@/views/components/uploadImage/photoUpload.vue";
import shooting from "@/views/components/camera/shooting";
import detectionAdd from "@/views/components/detection/add";
import diagnosisListDetail from "@/views/components/customerDetail/diagnosisListDetail1";
import treatmentDetail from "@/views/components/customerDetail/treatmentDetail";
import Screenfull from "@/components/Screenfull";
import { listClassify } from "@/api/system/classify";
import {
  fileOpen,
  directoryOpen,
  fileSave,
  supported,
} from "browser-fs-access";
import { getTipsList } from "@/api/warmReminder/warmReminder";
import { listText } from "@/api/system/text";
export default {
  name: "shareDetail",
  components: {
    Formpreview,
    comparePics,
    myImg,
    photoUpload,
    PhotoMark,
    shooting,
    detectionAdd,
    diagnosisListDetail,
    treatmentDetail,
    Screenfull,
  },
  dicts: [
    "sys_diagnosis_status",
    "sys_user_sex",
    "photo_upload_type",
    "photo_lighting_type",
    "sys_face_part",
    "sys_patient_properties",
    "sys_skin_tone",
    "sys_patient_sort",
    "sys_treatment_reaction",
    "sys_treatment_effect",
  ],
  data() {
    return {
      basicInfo: {
        patientId: this.$route.params.patientId,
        visitNum: this.$route.params.visitNum,
      },
      single: true, // 非单个禁用
      imageInfo: [], //上传的本地知情同意书照片信息
      confirmKnowVisible: false, // 遮罩层
      pictureDatileopen: false,
      patientItem: {},
      loading: true,
      loadingIndex: "",
      cycleTimer: null,
      baseUrl: process.env.VUE_APP_BASE_API,
      currentTab: "baseInfo",
      isActive: 0,
      areaList: [], // 省市区
      baseInfoForm: {
        id: 1,
        name: "王晓",
        sex: 0,
        age: 23,
        phoneNumber: "",
        IDnumber: "111001199010123210",
        wechat: "",
        wechatName: "",
        patientAddress: "",
        detailedAddress: "",
        visitDepartment: "皮肤科",
        status: 0,
        cardNumber: "121001",
        xingZhi: "临床",
        customerClassification: "vip",
        diagnosis: "诊断内容",
        PrediagnosisQuestionnaire: "未填写",
        pictures: 0,
        registerPerson: "登记护士",
        registrationDate: "2022-09-05 10:29:39",
        consultants: "咨询护士",
        consultationDate: "2022-09-05 11:39:19",
        doctorName: "诊断医生",
        firstVisitDate: "2022-09-05 15:36:49",
        consent: "是否接受咨询",
        treatmentPrograms: "别熬夜",
        numberOfTreatments: "3/10",
        remark: "备注内容",
        date: "",
      },
      queryParams: { pageNum: 1, pageSize: 10 },
      diagnosisQueryParams: {
        pageNum: 1,
        pageSize: 9999,
        visitNum: "",
        patientId: "",
      },
      treatmentRecordQueryParams: {
        pageNum: 1,
        pageSize: 10,
        visitNum: "",
        patientId: "",
      },
      treatmentRecordTotal: 0,
      baseInfoData: [],
      pictureForm: {
        photoLightingType: "",
        type: "",
        visitNum: "",
        patientId: "",
      }, // 拍摄照片表单
      questionForm: { visitNum: "" }, //诊前问卷表单
      prediagnosisQuestionnaireDataList: [],
      consentDataList: [],
      followupVisitDataList: [],
      diagnosisAndProjectDataList: [],
      treatmentRecordDataList: [],
      questionnaireTitle: "", // 诊前问卷弹出层标题
      consentDialog: false, // 知情同意书弹出层是否显示
      formpreviewContList: null, // 诊前问卷表单控件列表
      formBaseStatus: true,
      formpreviewContList1: null,
      formInfo: {},
      questionFormInfo: {
        name: "",
        remark: "",
      },
      questionFormInfo1: {
        name: "",
        remark: "",
      },
      questionFormInfo2: {
        name: "",
        remark: "",
      },
      picData: [],
      srcList: [],
      fileSizeListData: [], // 日期范围
      //专病问卷
      formInfo2: {},
      classifyList: [],
      formpreviewContList2: null,
      selectData: { formId: null, diseaseId: null }, //选中的表单
      questionnaireTitle2: "", // 诊前问卷弹出层标题
      questionnaireDialog2: false, // 诊前问卷弹出层是否显示
      dialogNewAddBtnStatus2: false, //诊前问卷弹窗新增或者修改状态
      formList: [], //表单列表
      //专病问卷
      dateRange: [],
      myAnswer: null, //存放表单答案
      myAnswer1: null, //存放表单答案 弹窗
      myAnswer2: null, //存放表单答案 弹窗
      activeName: 0,
      zqtysImg: require("@/assets/images/zqtys.jpg"),
      comparePicsDialogVisible: false,
      picMarkDialogVisible: false,
      currentUrl: "",
      imgList: [],
      myImgIndex: "",
      listDetectionVisit: [],
      detectionIndexForm: {
        pageNum: 1,
        pageSize: 10,
        visitNum: "",
        patientId: "",
      },
      Listtotal: 0,
      consentForm: {
        type: "1",
        visitNum: "",
        patientId: "",
      },
      //温馨提示
      warmReminderRecordParams: {
        pageNum: 1,
        pageSize: 9999,
        visitNum: "",
        patientId: "",
      },
      warmReminderRecordData: [],
      warmReminderClassifyList: [], // 专病表格数据
      warmReminderContent: {},
      warmReminderDialogVisible: false,
      consentSrcList: [],
      countAngle: {
        formLogCount: 0,
        nformedConsentCount: 0,
        photoCount: 0,
        treatmentCount: 0,
        visitCount: 0,
        doctorCount: 0,
        tipsCount: 0,
      },
      historyDiagnosisDialogVisible: false,
      historyDiagnosisList: [],
      historyDiagnosisSignalList: [],
      dialogNewAddBtnStatus: true, //问卷弹窗
      questionnaireDialog: false,
      cameraShootingVisible: false,
      cameraShootingType: "",
      blobs: [], //获取的知情同意书照片信息
      centerDialogVisible: false,
      baseAdd: { isDetail: false, isShow: 1 },
      planTitle: "",
      diagnosisDialogVisible: false,
      diagnosisTitle: "",
      baseInfo: { updateStatus: false, isDetail: 1 },
      isdiagnosisAdd: 3, //1 新增  2 修改 3不显示
      istreatAdd: 0, //0 不显示  1 添加  2 修改
      recordTitle: "治疗方案",
      recordVisible: false,
      recordbaseInfo: { updateStatus: true },
      submitStatus: true,
      ids: [], // 选中数组
    };
  },

  async created() {
    await setToken(this.$route.params.token);
    this.getAddressData();
    this.getPatientList();
  },
  computed: {
    ...mapGetters(["nickName", "userId", "isUpdate", "dept", "hospital"]),
    isAdmin() {
      return this.$store.state.user.name === "admin" ? true : false;
    },
  },
  async mounted() {
    // const el = this.$refs.myPhotoDiv
    // el.addEventListener('contextmenu', this.handleRightClick)
    await this.getCountAngle();
  },
  methods: {
    closeQuestion() {
      if (this.prediagnosisQuestionnaireDataList.length > 0) {
        this.formBaseStatus = true;
        this.openQuestionnaire(
          this.prediagnosisQuestionnaireDataList[this.isActive],
          this.isActive
        );
      }
    },
    handleRightClick(event) {
      event.preventDefault();
    },
    downLoadphoto(url, item, name) {
            const imgUrl = url;// 图片链接
            // const a = document.createElement('a');
            // 这里是将url转成blob地址，
            let that = this
            fetch(imgUrl)  // 跨域时会报错
                .then(res => res.blob())
                .then(blob => { // 将链接地址字符内容转变成blob地址
                    that.convertToJPG(URL.createObjectURL(blob), 1, function (dataURL) {
                        // 这里的dataURL就是转换后的JPG图像的DataURL
                        // 如果需要将此图像下载为文件，可以使用以下代码
                        var link = document.createElement('a');
                        link.href = dataURL;
                        link.download = name + ' ' + item.visitNum + '(采集时间：' + item.createTime + ')';  //imgUrl.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0] 下载文件的名字
                        document.body.appendChild(link);
                        link.click();
                        window.URL.revokeObjectURL(link.href);
                        document.body.removeChild(link);
                    });
                })
        },
        convertToJPG(sourceImage, quality, callback) {
            var image = new Image();
            image.src = sourceImage;
            image.onload = function () {
                var canvas = document.createElement('canvas');
                console.log(canvas)
                canvas.width = image.width;
                canvas.height = image.height;
                var ctx = canvas.getContext('2d');
                ctx.drawImage(image, 0, 0);
                var dataURL = canvas.toDataURL('image/jpeg', quality);
                callback(dataURL);
            };
        },
    getTreatmentReactionText(value) {
      let text = "";
      if (value.includes(",")) {
        let data = value.split(",");
        data.forEach((item, index) => {
          this.dict.type.sys_treatment_reaction.forEach((row) => {
            if (item === row.value) {
              if (index + 1 < data.length) {
                text = `${text + row.label},`;
              } else {
                text += row.label;
              }
            }
          });
        });
      } else {
        this.dict.type.sys_treatment_reaction.forEach((row) => {
          if (value === row.value) {
            text = row.label;
          }
        });
      }
      return text;
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);

      this.single = selection.length != 1;
    },
    delPics(pIndex) {
      const that = this;
      that
        .$prompt("请输入删除照片原因", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        })
        .then(({ value }) => {
          delPhotoByGroup(pIndex).then((res) => {
            that.refreshList(2);
            that.$modal.msgSuccess("删除成功");
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      console.log("getSummaries---", param);
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (column.label == "治疗价格") {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] += " 元";
        } else {
          sums[index] = "";
        }
      });

      return sums;
    },
    gethospital(str) {
      if (str) {
        return str;
      } else {
        return "";
      }
    },
    //专病问卷
    getClassifyList() {
      listClassify({ pageNum: 1, pageSize: 9999 }).then((response) => {
        this.classifyList = response.rows;
      });
    },
    addQuestionnaire2() {
      //新增专病问卷
      this.formBaseStatus = false;
      this.selectData.formId = null;
      this.formpreviewContList2 = null;
      this.questionnaireDialog2 = true;
      this.dialogNewAddBtnStatus2 = true;
      this.questionnaireTitle2 = "新增顾客专病诊前问卷";
    },
    async addQuestionForm2() {
      this.selectData.diseaseId = null;
      this.selectData.formId = null;
      this.formpreviewContList2 = null;
      this.dialogNewAddBtnStatus2 = true;
      this.formList = [];
      this.questionnaireTitle2 = "新增顾客专病问卷";
    },
    changeQuestionFormAdd() {
      let that = this;
      that.getClassifyList();
      that.baseInfoData.forEach(function (ele) {
        if (ele.visitNum == that.questionForm.visitNum) {
          console.log("___专病————");
          console.log(ele);
          that.formInfo2 = ele;
        }
      });
    },
    //提交答案
    submitAnswer2() {
      const that = this;
      that.$nextTick(() => {
        that.$refs.formPreview.$refs.listForm.validate((valid) => {
          console.log(that.$refs.formPreview.$refs.listForm);
          if (valid) {
            let answerArr = [];
            const Vmodel = that.$refs.formPreview.$refs.listForm.model;
            Object.keys(Vmodel).forEach((item) => {
              answerArr.push({ answer: Vmodel[item], questionId: null });
            });
            that.formpreviewContList2.forEach((item, index) => {
              that.$set(answerArr[index], "questionId", item.questionId);
            });
            let answerStr = JSON.stringify(answerArr);
            let mData = {
              visitId: that.formInfo2.visitId,
              patientId: that.formInfo2.patientId,
              formId: that.formInfo2.formId,
              answer: answerStr,
              formType: "1", //专病表单
            };
            addFormAnswer(1, mData).then((response) => {
              that.$message.success("提交成功");
              that.questionnaireDialog2 = false;
              this.refreshList(1);
            });
          }
        });
      });
    },
    // 通过formid获取form内容
    getFormContByFormId(current) {
      if (current == "") {
        return;
      }
      listFormCont({
        formId: current,
      }).then((response) => {
        this.questionFormInfo2.name = response.name;
        this.questionFormInfo2.remark = response.remark;
        this.formpreviewContList2 = response.rows;
        let mAnswer = null;
        if (this.dialogNewAddBtnStatus2 === false) {
          this.myAnswer2.forEach((it) => {
            if (it.formId === current) {
              mAnswer = JSON.parse(it.answer);
              this.formInfo2.visitLogId = it.visitLogId;
            }
          });
        }
        this.formpreviewContList2.forEach((item, index) => {
          if (this.dialogNewAddBtnStatus2 === false) {
            this.$set(item, "answer", mAnswer[index].answer);
          } else {
            if (item.questionType == "2") {
              this.$set(item, "answer", []);
            } else {
              this.$set(item, "answer", null);
            }
          }
        });
      });
      this.formInfo2.formId = current;
      console.log(this.formList);
    },
    /** 修改顾客专病诊前问卷按钮操作 */
    updateQuestionnaire2(row) {
      this.formpreviewContList2 = null;
      this.formInfo = row;
      this.selectData.formId = null;
      this.questionnaireTitle2 = "修改顾客专病诊前问卷";
      this.questionnaireDialog2 = true;
      this.dialogNewAddBtnStatus2 = false;
      diseaseQuestionnaireList(this.formInfo.visitId).then((response) => {
        this.myAnswer2 = response.data;
        console.log("点击修改按钮获取的答案和表单列表", this.myAnswer2);
        this.formList = this.myAnswe2;
        this.selectData.formId = response.data[0].formId;
        this.getFormContByFormId(this.myAnswer[0].formId);
      });
    },
    /** 查询表单列表 */
    getFormList(diseaseId) {
      this.selectData.formId = null;
      let hospitalId;
      if (this.hospital.ancestors == "0") {
        hospitalId = "";
      } else {
        hospitalId = this.hospital.deptId;
      }
      listForm(
        this.addDateRange({
          pageNum: 1,
          formType: "1",
          diseaseId: diseaseId,
          pageSize: 9999,
          hospitalId: hospitalId,
          status: "0",
        })
      ).then((response) => {
        this.formList = response.rows;
        //（目前先所有专病问卷，稍后补充）通用和专病混在一起了  这里跟之前单独的逻辑不一样了  这里还要把通用的问卷过滤除去 再把已填写的专病过滤出
        // let newArr = [];
        // console.log(this.myAnswer2)
        // //新增时过滤已经新增的  修改时只有已修改的
        // if (this.dialogNewAddBtnStatus2) {
        //     for (let i = 0; i < this.formList.length; i++) {
        //         if (!this.myAnswer2.find((item) => item.formId == this.formList[i].formId)) {
        //             newArr.push(this.formList[i]);
        //         }
        //     }
        // }
        // this.formList = newArr;
      });
    },
    //治疗方案
    newAddtreat() {
      this.recordbaseInfo.updateStatus = true;
      this.submitStatus = true;
      this.recordVisible = true;
    },
    newUptreat() {
      const id = this.ids[0];
      this.recordbaseInfo.treatmentId = id;
      this.recordbaseInfo.updateStatus = true;
      this.submitStatus = false;
      this.recordVisible = true;
    },
    closerecordDialogVisible() {
      this.recordVisible = false;
      this.refreshList(6);
    },
    //诊断方案
    newAdddiagnosis() {
      //
      this.baseInfo.updateStatus = false;
      this.baseInfo.isDetail = 1;
      this.baseInfo.referenceStatus = false;
      this.diagnosisTitle = "新增方案";
      this.diagnosisDialogVisible = true;
      this.$refs.Screenfull.open();
    },
    updatePlandiagnosis() {
      this.baseInfo.updateStatus = true;
      this.baseInfo.referenceStatus = false;
      this.diagnosisTitle = "修改方案";
      this.diagnosisDialogVisible = true;
      this.$refs.Screenfull.open();
    },
    changeIsdiagnosisAdd() {
      let that = this;
      console.log("刷新按钮了");
      that.baseInfoData.forEach(function (ele) {
        if (ele.visitNum == that.diagnosisQueryParams.visitNum) {
          that.baseInfo = ele;
          console.log(Number(ele.status));
          if (Number(ele.status) < 3) {
            that.isdiagnosisAdd = 1;
            // && arr[0].doctor == that.nickName
          } else if (Number(ele.status) == 3) {
            that.isdiagnosisAdd = 2;
          } else {
            that.isdiagnosisAdd = 3;
          }
        }
      });
    },
    changeIstreatAdd() {
      let that = this;
      console.log("刷新按钮了");
      that.baseInfoData.forEach(function (ele) {
        if (ele.visitNum == that.treatmentRecordQueryParams.visitNum) {
          console.log(Number(ele.status));
          that.recordbaseInfo = ele;
          if (Number(ele.status) < 3) {
            that.istreatAdd = 0;
          } else if (Number(ele.status) == 3) {
            that.istreatAdd = 1;
          } else if (Number(ele.status) > 3) {
            that.istreatAdd = 2;
            console.log("今日  222");
          } else {
            that.istreatAdd = 0;
          }
        }
      });
    },
    closefullScreen() {
      this.$refs.Screenfull.closed();
    },
    closediagnosisDialogVisible() {
      this.diagnosisDialogVisible = false;
      this.refreshList(5);
      this.getPatientList();
    },
    // 录入指标 saveDetection
    handleAdd() {
      //新增检测指标
      this.baseAdd = {};
      this.baseAdd.isDetail = true;
      this.baseAdd.isShow = 1;
      this.baseAdd.visitNum = this.detectionIndexForm.visitNum;
      this.baseAdd.patientName = this.detectionIndexForm.patientName;
      this.baseAdd.patientId = this.detectionIndexForm.patientId;
      console.log(this.baseAdd);
      this.planTitle = "检测指标";
      this.centerDialogVisible = true;
    },
    closeCenterDialogVisible() {
      this.centerDialogVisible = false;
      this.refreshList(8);
    },
    //调取摄像头拍摄
    openShooting(type) {
      this.cameraShootingVisible = true;
      this.cameraShootingType = type;
    },
    //关闭摄像头拍摄
    closeShooting(imgSrc, imgFile) {
      this.cameraShootingVisible = false;
      this.blobs = [];
      this.imageInfo = [];
      this.blobs.push(imgFile);
      this.imageInfo.push({ url: imgSrc });
    },
    //获取已上传的缴费凭证或知情同意书
    getConsentList1(visitNum, type) {
      consentList(visitNum, type).then((response) => {
        if (response.code == 200) {
          this.imageInfo = response.data;
          this.imageInfo.forEach((item) => {
            item.url = this.baseUrl + item.url;
          });
          this.loading = false;
        } else {
          this.$modal.msgError(response.msg);
          this.loading = false;
        }
      });
    },
    //删除图片
    removeImg(img, idx) {
      this.$confirm("此操作将删除该照片, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.imageInfo = this.imageInfo.filter((item) => {
            return item.url != img.url;
          });
          this.blobs.splice(idx, 1);
        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //获取图片
    async uploadImage() {
      const blobs = await fileOpen({
        mimeTypes: ["image/*"],
        multiple: true,
      });

      this.blobs.push(...blobs);
      // console.log('uploadImage-blobs-',this.blobs )
      this.imageInfo = [];
      this.blobs.forEach((item, index) => {
        const reader = new FileReader();
        reader.readAsDataURL(item);
        reader.onload = () => {
          this.imageInfo.push({ url: reader.result });
        };
      });
      console.log("imageInfo--", this.imageInfo);
    },
    //关闭知情同意书
    closeConfirmKnow() {
      this.confirmKnowVisible = false;
      this.blobs = []; //获取的知情同意书照片信息
      this.imageInfo = []; //上传的本地知情同意书照片信息
    },
    //打开知情同意书
    confirmKnow() {
      this.confirmKnowVisible = true;
      this.getConsentList1(this.consentForm.visitNum, "1");
    },
    //确认已签署
    handleCloseConfirmKnow(type) {
      if (this.blobs.length == 0) {
        this.$modal.msgWarning("请上传图片");
        return;
      }
      this.loading = true;

      // 创建FormData对象，通过该对象实现批量文件上传
      let fd = new FormData();
      // 因为要上传多个文件，所以需要遍历一下才行,不要直接使用我们的文件数组进行上传，你会发现传给后台的是两个Object
      this.blobs.forEach(function (file) {
        // 遍历files数组，将file添加到FormData对象中
        fd.append("files", file, file.name);
        // console.log('fd.append',file,fd.getAll('files'))
      });
      let Mdata = {
        type: type,
        visitNum: this.consentForm.visitNum,
        data: fd,
      };
      consentUploads(Mdata).then((response) => {
        if (response.code == 200) {
          this.loading = false;
          this.$modal.msgSuccess(response.msg);
          this.confirmKnowVisible = false;
          this.blobs = []; //获取的知情同意书照片信息
          this.imageInfo = []; //上传的本地知情同意书照片信息
          this.refreshList(3);
        } else {
          this.loading = false;
          this.$modal.msgError(response.msg);
        }
      });
    },
    getCountAngle() {
      const patientId = this.basicInfo.patientId;
      getAngleCount(patientId).then((res) => {
        this.countAngle = res.data;
      });
    },
    // 真实序号计算（计算分页影响）
    getIndex(index) {
      return (
        (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
      );
    },
    getTreatmentRecordIndex(index) {
      return (
        (this.treatmentRecordQueryParams.pageNum - 1) *
          this.treatmentRecordQueryParams.pageSize +
        index +
        1
      );
    },
    getDetectionIndexFormIndex(index) {
      return (
        (this.detectionIndexForm.pageNum - 1) *
          this.detectionIndexForm.pageSize +
        index +
        1
      );
    },
    //获取诊断状态字典值对应的label
    getDiagnosisStatusLabel(status) {
      let label = "";
      this.dict.type.sys_diagnosis_status.forEach((item) => {
        if (item.value == status) {
          label = item.label;
        }
      });
      return label;
    },

    // 获取顾客登记列表
    getPatientList(type) {
      const patientId = this.basicInfo.patientId;
      const queryParams = { pageNum: 1, pageSize: 9999, patientId: patientId };
      getVisit(queryParams).then((response) => {
        this.baseInfoData = response.rows;
        this.baseInfoData.forEach((item) => {
          item.doctorDiagnosis = item.doctorDiagnosis.replace(
            / *\([^)]*\) */g,
            ""
          );
        });
        if (type == 5) {
          this.changeIsdiagnosisAdd();
        } else if (type == 6) {
          this.changeIstreatAdd();
        }
        // this.baseInfoData.forEach(item => {
        //     item.area = [
        //         Number(item.provinceId),
        //         Number(item.cityId),
        //         Number(item.countyId),
        //     ];
        // })
      });
    },
    getPicPreviewList(row) {
      this.srcList = [];
      this.fileSizeListData = [];
      row.sysPatientPhotos.forEach((it) => {
        this.srcList.push(it.photoAddress);
        this.fileSizeListData.push(
          `<div>姓名:${it.patientName}</div><div>年龄:${
            it.age
          }</div><div >医生诊断:${
            it.doctorDiagnosis
          }</div><div>采集状态:${this.matchDict(
            "sys_diagnosis_status",
            it.status
          )}</div><div>采集设备:${this.matchDict(
            "photo_upload_type",
            it.type
          )}</div><div>采集日期:${it.createTime}</div><div>采集人:${
            it.nickName
          }</div><div >${
            it.scoreAi ? "Ai mMASI评分:" + it.scoreAi + "分" : ""
          } </div ><div style='margin-top:20px'>光照类型:${this.matchDict(
            "photo_lighting_type",
            it.faceLight
          )}</div><div>部位:${this.matchDict(
            "sys_face_part",
            it.facePart
          )}</div><div>文件大小:${(it.fileSize / 1024 / 1024).toFixed(
            2
          )}M</div><div>压缩比:${it.compressionRatio}</div>`
        );
      });
    },
    /** id转化成对应的文字 */
    matchDict: function (key, id) {
      let _this = this;
      const result = _this.dict.type[key];
      let textValue = "";
      result.forEach((item) => {
        if (item.raw.dictValue == id) {
          textValue = item.raw.dictLabel;
        }
      });
      return textValue;
    },
    // 真实序号计算（计算分页影响）
    getWarmReminderRecordIndex(index) {
      return (
        (this.warmReminderRecordParams.pageNum - 1) *
          this.warmReminderRecordParams.pageSize +
        index +
        1
      );
    },
    //温馨提示记录
    getWarmReminderRecord() {
      getTipsList(this.warmReminderRecordParams).then((response) => {
        if (response.code == 200) {
          this.warmReminderRecordData = response.rows;
          listText({
            pageNum: 1,
            pageSize: 9999,
            diseaseId: "",
          }).then((res) => {
            this.warmReminderClassifyList = res.rows;
          });
        } else {
        }
      });
    },
    lookRecordItem(row) {
      this.warmReminderDialogVisible = true;
      this.warmReminderForm = row;
      this.warmReminderContent = this.warmReminderClassifyList.find((item) => {
        return item.textId == this.warmReminderForm.textId;
      });
    },
    handleconsentDialog(row) {
      this.consentDialog = true;
    },
    /** 知情同意书 */
    getConsentList() {
      consentListAll(this.consentForm).then((response) => {
        if (response.code == 200) {
          this.consentDataList = response.data;
          console.log("getConsentList---", response);
        } else {
          this.$modal.msgError(response.msg);
        }
      });
    },
    getConsentPreviewList(row) {
      this.consentSrcList = [];
      row.sysNformedConsents.forEach((it) => {
        this.consentSrcList.push(this.baseUrl + it.url);
      });
    },
    //添加照片
    addphoto() {
      let that = this;
      console.log(that.baseInfoData);
      that.baseInfoData.forEach(function (ele) {
        if (ele.visitNum == that.pictureForm.visitNum) {
          console.log(ele);
          that.patientItem = ele;
          that.pictureDatileopen = true;
        }
      });
    },
    addQuestionnaire() {
      //新增诊前问卷
      this.formBaseStatus = false;
      this.formInfo.patientId = this.basicInfo.patientId;
      let hospitalId;
      if (this.hospital.ancestors == "0") {
        hospitalId = "";
      } else {
        hospitalId = this.hospital.deptId;
      }
      currencyFormId({ deptId: hospitalId }).then((res) => {
        if (res.code == 200) {
          let that = this;
          that.formInfo.formId = res.data;
          console.log(that.prediagnosisQuestionnaireDataList);
          if (res.data) {
            that.baseInfoData.forEach(function (ele) {
              if (ele.visitNum == that.questionForm.visitNum) {
                that.formInfo.visitId = ele.visitId;
                that.getFormContList1();
              }
            });
            that.dialogNewAddBtnStatus = true;
            that.questionnaireTitle = "新增顾客通用诊前问卷";
          }
        }
      });
    },
    /** 弹窗查询表单内容控件列表 */
    getFormContList1() {
      listFormCont({
        formId: this.formInfo.formId,
      }).then((response) => {
        this.questionFormInfo1.name = response.name;
        this.questionFormInfo1.remark = response.remark;
        this.formpreviewContList1 = response.rows;
        this.formpreviewContList1.forEach((item, index) => {
          if (this.dialogNewAddBtnStatus === false) {
            this.$set(item, "answer", this.myAnswer1[index].answer);
          } else {
            if (item.questionType === "2") {
              this.$set(item, "answer", []);
            } else {
              this.$set(item, "answer", null);
            }
          }
        });
      });
      this.questionnaireDialog = true;
    },
    /** 修改诊前问卷按钮操作 */
    updateQuestionnaire() {
      this.dialogNewAddBtnStatus = false;
      this.formInfo.patientId = this.basicInfo.patientId;
      let that = this;
      this.baseInfoData.forEach(function (ele) {
        if (ele.visitNum == that.questionForm.visitNum) {
          that.formInfo.visitId = ele.visitId;
          getQuestionnaireCommon(ele.visitId).then((response) => {
            const visitLogId = response.data[0].visitLogId;
            console.log("点击修改按钮获取的答案和表单列表", that.myAnswer1);
            detailFormAndAnswer(visitLogId).then((response) => {
              that.formInfo = response.data;
              that.myAnswer1 = JSON.parse(response.data.answer);
              that.getFormContList1();
            });
          });
          that.questionnaireTitle = "修改顾客通用诊前问卷";
        }
      });
    },
    //新增诊前问卷
    submitAnswer() {
      this.$nextTick(() => {
        this.$refs.formPreview.$refs.listForm.validate((valid) => {
          console.log(this.$refs.formPreview.$refs.listForm);
          if (valid) {
            let answerArr = [];
            const Vmodel = this.$refs.formPreview.$refs.listForm.model;
            Object.keys(Vmodel).forEach((item) => {
              answerArr.push({ answer: Vmodel[item], questionId: null });
            });
            this.formpreviewContList1.forEach((item, index) => {
              this.$set(answerArr[index], "questionId", item.questionId);
            });
            let answerStr = JSON.stringify(answerArr);
            let mData = {
              visitId: this.formInfo.visitId,
              patientId: this.formInfo.patientId,
              formId: this.formInfo.formId,
              answer: answerStr,
              formType: 0, //通用表单
            };
            addFormAnswer(1, mData).then((response) => {
              if (response.code == 200) {
                this.$message.success("提交成功");
                this.questionnaireDialog = false;
                this.refreshList(1);
              }

              // this.getFormContList()
            });
          }
        });
      });
    },
    /** 修改诊前问卷按钮操作 */
    async updateFormAnswer() {
      this.$nextTick(() => {
        this.$refs.formPreview.$refs.listForm.validate((valid) => {
          if (valid) {
            let answerArr = [];
            const Vmodel = this.$refs.formPreview.$refs.listForm.model;
            Object.keys(Vmodel).forEach((item) => {
              answerArr.push({ answer: Vmodel[item], questionId: null });
            });
            this.formpreviewContList.forEach((item, index) => {
              this.$set(answerArr[index], "questionId", item.questionId);
            });
            let answerStr = JSON.stringify(answerArr);
            let mData = {
              visitLogId: this.formInfo.visitLogId,
              answer: answerStr,
            };
            console.log(this.formInfo.visitLogId);
            updateAnswer(1, mData).then((response) => {
              if (response.code == 200) {
                this.$message.success("修改成功");
                this.questionnaireDialog = false;
                this.refreshList(1);
              }
            });
          }
        });
      });
    },
    refreshList(type) {
      if (type == 1) {
        //诊前问卷
        this.formBaseStatus = true;
        this.formInfo.patientId = this.basicInfo.patientId;
        let that = this;
        that.getListCustomerForm();
        // this.baseInfoData.forEach(function (ele) {
        //     if (ele.visitNum == that.questionForm.visitNum) {
        //         that.formInfo.visitId = ele.visitId
        //         getQuestionnaireCommon(ele.visitId).then((response) => {
        //           console.log('getQuestionnaireCommon----',response)
        //             const visitLogId = response.data[that.isActive].visitLogId;
        //             detailFormAndAnswer(visitLogId).then((response) => {
        //                 that.formInfo = response.data;
        //                 that.myAnswer = JSON.parse(response.data.answer);
        //                 that.getFormContList();
        //             });
        //         });
        //         that.getListCustomerForm()
        //     }
        // })
      } else if (type == 2) {
        //照片
        this.getPhotoList();
        this.pictureDatileopen = false;
      } else if (type == 3) {
        //知情同意书
        this.getConsentList();
      } else if (type == 4) {
        //温馨提示
      } else if (type == 5) {
        //诊断方案
        this.getDiagnosisAndProject();
        this.getPatientList(5);
      } else if (type == 6) {
        //治疗
        this.getTreatmentList();
        this.getPatientList(6);
      } else if (type == 8) {
        //检测指标
        this.getlistDetectionVisit();
      }
      this.getCountAngle();
    },
    /** 诊前问卷按钮操作 */
    async openQuestionnaire(row, index) {
      this.isActive = index;
      this.formInfo = row;
      if (row) {
        this.myAnswer = JSON.parse(row.answer);
        await this.getFormContList();
        this.questionnaireTitle = row.name;
      }
    },
    // 获取地区
    getAddressData() {
      addressJson().then((res) => {
        this.areaList = res.data;
      });
    },

    //根据病人id获取图片列表
    getPhotoList(index) {
      listPhoto(this.addDateRange(this.pictureForm, this.dateRange)).then(
        (res) => {
          let that = this;
          if (res.data.length > 0) {
            this.picData = res.data;
            this.picData.forEach((item, indexs) => {
              item.scoreAiAll = 0;
              item.sysPatientPhotos.forEach((it) => {
                if (it.score && JSON.parse(it.score).left) {
                  it.scoreAi =
                    0.3 *
                    JSON.parse(it.score).left.area *
                    JSON.parse(it.score).left.color;
                  if (indexs === index) {
                    this.loadingIndex = "";
                    this.$message.success("Ai分析成功");
                    clearInterval(that.cycleTimer);
                  }
                }
                if (it.score && JSON.parse(it.score).brow) {
                  it.scoreAi =
                    0.3 *
                      JSON.parse(it.score).brow.area *
                      JSON.parse(it.score).brow.color +
                    0.1 *
                      JSON.parse(it.score).chin.area *
                      JSON.parse(it.score).chin.color;
                  if (indexs === index) {
                    this.loadingIndex = "";
                    // this.$message.success("Ai分析成功");
                    clearInterval(that.cycleTimer);
                  }
                }
                if (it.score && JSON.parse(it.score).right) {
                  it.scoreAi =
                    0.3 *
                    JSON.parse(it.score).right.area *
                    JSON.parse(it.score).right.color;
                  if (indexs === index) {
                    this.loadingIndex = "";
                    // this.$message.success("Ai分析成功");
                    clearInterval(that.cycleTimer);
                  }
                }
                if (it.scoreAi != null) {
                  item.scoreAiAll += it.scoreAi;
                }
                it.patientName = item.patientName;
                it.age = item.age;
                it.doctorDiagnosis = item.doctorDiagnosis.replace(
                  / *\([^)]*\) */g,
                  ""
                );
                it.points = this.formatPoints(it.points);
              });
            });
            console.log("this.picData---", this.picData);
          } else {
            this.picData = [];
          }
        }
      );
    },
    //格式化画图组件点位格式数据
    formatPoints(data) {
      if (data != null) {
        let mData = [];
        console.log(JSON.parse(data));
        JSON.parse(data).forEach((item, index) => {
          let itPoint = [];
          item.forEach((it, mindex) => {
            itPoint.push({ x: it[0], y: it[1] });
            if (item.length - 1 === mindex) {
              //最后一个点连接到第一个点形成闭合
              itPoint.push({ x: item[0][0], y: item[0][1] });
            }
          });
          mData.push({ points: itPoint, type: "route" });
        });
        console.log(mData);
        return mData;
      } else {
        return null;
      }
    },
    watchBigPic(row, Mindex) {
      this.myImgIndex = Mindex;
      this.currentUrl = row.sysPatientPhotos[Mindex].photoAddress;
      row.sysPatientPhotos.forEach((item) => {
        item.patientName = row.patientName;
        item.age = row.age;
        item.doctorDiagnosis = row.doctorDiagnosis.replace(
          / *\([^)]*\) */g,
          ""
        );
      });
      this.imgList = row.sysPatientPhotos;
      this.picMarkDialogVisible = true;
    },
    //启动黄褐斑AI
    startHhbAi(item, index) {
      let that = this;
      if (this.loadingIndex) {
        this.$confirm("已有照片正在评分,请稍后再试!", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {})
          .catch(() => {});
        return;
      }
      if (item.scoreAiAll) {
        this.$confirm("已有Ai mMASI评分,请确定是否进行重新评分?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            if (that.cycleTimer) {
              clearInterval(that.cycleTimer);
            }
            this.startHhbAiAgain(item, index);
          })
          .catch(() => {
            return;
          });
      } else {
        this.startHhbAiAgain(item, index);
      }
    },
    startHhbAiAgain(item, index) {
      let photoIds = [];
      let comparePhotoIds = [];
      let photoItem1 = item.sysPatientPhotos.find((it) => {
        return it.faceLight == "1" && it.facePart == "0";
      });
      let photoItem2 = item.sysPatientPhotos.find((it) => {
        return it.faceLight == "1" && it.facePart == "1";
      });
      let photoItem3 = item.sysPatientPhotos.find((it) => {
        return it.faceLight == "1" && it.facePart == "2";
      });
      item.sysPatientPhotos.forEach((it) => {
        if (it.faceLight == "1" && it.facePart == "0") {
          comparePhotoIds.push(it.photoId);
        }
        if (it.faceLight == "1" && it.facePart == "1") {
          comparePhotoIds.push(it.photoId);
        }
        if (it.faceLight == "1" && it.facePart == "2") {
          comparePhotoIds.push(it.photoId);
        }
      });
      if (
        photoItem1 &&
        photoItem2 &&
        photoItem3 &&
        comparePhotoIds.length == 3
      ) {
        photoIds.push(photoItem1.photoId);
        photoIds.push(photoItem2.photoId);
        photoIds.push(photoItem3.photoId);
        photoIds = photoIds.join(",");
        console.log("photoIds---", photoIds);
        startAi({ photoIds: photoIds, type: "0" }).then((response) => {
          if (response.code == 200) {
            let that = this;
            that.loadingIndex = item.p_index;
            if (item.scoreAiAll) {
              setTimeout(function () {
                that.getPhotoList(index);
              }, 9000);
            } else {
              that.cycleTimer = setInterval(function () {
                console.log("每隔3s执行一次");
                that.getPhotoList(index);
              }, 3000);
            }
          }
        });
      } else {
        this.$confirm(
          `无法进行Ai分析,Ai分析需光照类型为<strong>Standard</strong>,且脸部部位为<strong>左面部, 正面部, 右面部</strong>有且有三张!`,
          "提示",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
            dangerouslyUseHTMLString: true,
          }
        )
          .then(() => {
            return;
          })
          .catch(() => {
            return;
          });
      }
    },
    //筛选值

    //tab点击切换
    tabHandleClick(tab, event) {
      if (tab.name === "PrediagnosisQuestionnaire") {
        this.isActive = 0;
        this.questionForm.visitNum = this.basicInfo.visitNum;
        this.getListCustomerForm();
      }
      if (tab.name === "pictures") {
        this.pictureForm.visitNum = this.basicInfo.visitNum;
        this.pictureForm.patientId = this.basicInfo.patientId;
        this.getPhotoList();
      }
      if (tab.name === "consent") {
        this.consentForm.visitNum = this.basicInfo.visitNum;
        this.consentForm.patientId = this.basicInfo.patientId;
        this.getConsentList();
      }
      if (tab.name === "warmReminder") {
        this.warmReminderRecordParams.visitNum = this.basicInfo.visitNum;
        this.warmReminderRecordParams.patientId = this.basicInfo.patientId;
        this.getWarmReminderRecord();
      }
      if (tab.name === "followupVisitDataList") {
        this.getListCustomerForm();
      }
      if (tab.name === "diagnosisAndProject") {
        this.diagnosisQueryParams.visitNum = this.basicInfo.visitNum;
        this.diagnosisQueryParams.patientId = this.basicInfo.patientId;
        // this.getDiagnosisAndProject()
        this.refreshList(5);
      }
      if (tab.name === "treatmentRecord") {
        this.treatmentRecordQueryParams.visitNum = this.basicInfo.visitNum;
        this.treatmentRecordQueryParams.patientId = this.basicInfo.patientId;
        // this.getTreatmentList()
        this.refreshList(6);
      }
      if (tab.name === "detectionIndex") {
        this.detectionIndexForm.visitNum = this.basicInfo.visitNum;
        this.detectionIndexForm.patientId = this.basicInfo.patientId;
        this.detectionIndexForm.patientName = this.basicInfo.patientName;
        this.getlistDetectionVisit();
      }
    },
    //获取指标录入列表
    getlistDetectionVisit() {
      listDetectionVisit(this.detectionIndexForm).then((response) => {
        if (response.rows.length > 0) {
          this.listDetectionVisit = response.rows;
          this.Listtotal = response.total;
          console.log(this.Listtotal);
          this.loading = false;
        } else {
          this.listDetectionVisit = [];
          this.Listtotal = 0;
          this.loading = false;
        }
      });
    },
    getLabel(row) {
      let labeltext = "";
      if (
        row.hightValue != "" &&
        row.hightValue != null &&
        row.limitValue != "" &&
        row.limitValue != null
      ) {
        //文本值
        if (
          Number(row.hightValue) >= Number(row.detectionValue) &&
          Number(row.detectionValue) >= Number(row.limitValue)
        ) {
          labeltext = "正常";
        } else {
          labeltext = "异常";
        }
      } else if (
        (row.hightValue == "" || row.hightValue == null) &&
        row.defaultValue != "" &&
        row.defaultValue != null
      ) {
        if (row.detectionValue == row.defaultValue) {
          labeltext = "正常";
        } else {
          labeltext = "异常";
        }
      }
      return labeltext;
    },
    comparePics() {
      this.comparePicsDialogVisible = true;
    },
    // 获取顾客登记列表
    getDiagnosisAndProject() {
      // const patientId = this.basicInfo.patientId
      // const queryParams = { pageNum: 1, pageSize: 9999, patientId: patientId }
      // listVisitTip(queryParams).then((response) => {
      //     this.diagnosisAndProjectDataList = response.rows.filter((item) => Number(item.status) >= 3);
      // });

      listVisitTip(this.diagnosisQueryParams).then((response) => {
        this.diagnosisAndProjectDataList = response.rows.filter(
          (item) => Number(item.status) >= 1
        );
        this.diagnosisAndProjectDataList.forEach((item) => {
          if (item.doctorDiagnosis.includes(";")) {
            let MobjectDoctor = "";
            item.doctorDiagnosis.split(";").forEach((it) => {
              MobjectDoctor += it + "<br>";
            });
            item.doctorDiagnosis = MobjectDoctor;
          }
          if (item.consultationDiagnosis.includes(";")) {
            let Mobject = "";
            item.consultationDiagnosis.split(";").forEach((it) => {
              Mobject += it + "<br>";
            });
            item.consultationDiagnosis = Mobject;
          }
        });
      });
    },
    //获取该就诊编号的医生诊断信息
    goHistoryDiagnosis(row) {
      this.historyDiagnosisDialogVisible = true;
      this.historyDiagnosisSignalList = [];

      myHistoryDiagnosis(row.visitNum).then((response) => {
        // console.log('goMoreDiagnosis---',response)
        if (response.data.length > 0) {
          this.historyDiagnosisList = response.data;
          response.data.forEach((item) => {
            item.sysVisitPlan.nick_name = item.nick_name;
            item.sysVisitPlan.patientName = row.patientName;
            if (item.sysVisitPlan.diagnosis.includes(";")) {
              let MobjectDoctor = "";
              item.sysVisitPlan.diagnosis.split(";").forEach((it) => {
                MobjectDoctor += it + "<br>";
              });
              item.sysVisitPlan.diagnosis = MobjectDoctor;
            }
          });
          this.historyDiagnosisSignalList = response.data.map((item) => {
            return item.sysVisitPlan;
          });

          console.log(
            "historyDiagnosisSignalList",
            this.historyDiagnosisSignalList
          );
        }
      });
    },
    // 获取顾客治疗列表
    getTreatmentList() {
      getTreatmentList(this.treatmentRecordQueryParams).then((response) => {
        if (response.code == 200) {
          this.treatmentRecordDataList = response.rows;
          this.treatmentRecordTotal = response.total;
        } else {
          this.$modal.msgError(response.msg);
        }
      });
    },
    /** 查询表单内容控件列表 */
    getFormContList() {
      listFormCont({
        formId: this.formInfo.formId,
      }).then((response) => {
        this.questionFormInfo.name = response.name;
        this.questionFormInfo.remark = response.remark;
        this.formpreviewContList = response.rows;
        this.formpreviewContList.forEach((item, index) => {
          this.$set(item, "answer", this.myAnswer[index].answer);
        });
      });
    },

    /** 查询顾客表单列表 */
    getListCustomerForm() {
      let that = this;
      let index = that.isActive;
      that.changeQuestionFormAdd();
      if (this.baseInfoData.length > 0) {
        const patientId = this.basicInfo.patientId;
        // this.questionForm.visitNum = this.baseInfoData[0].visitNum
        listCustomerForm({
          patientId: patientId,
          visitNum: this.questionForm.visitNum,
        }).then((response) => {
          that.prediagnosisQuestionnaireDataList = response.rows;
          if (response.rows.length > 0) {
            that.openQuestionnaire(response.rows[index]);
            that.isActive = index;
          } else {
            that.formpreviewContList = null;
          }
        });
      }
    },
  },
};
</script>
<style scoped rel="stylesheet/scss" lang="scss">
.date-header {
  line-height: 60px;
  color: red;
}

.treatment-tips {
  text-align: center;
  line-height: 60px;
}

.img-txt:hover {
  .downBtn {
    position: absolute;
    top: 10px;
    right: 0px;
    display: block;
  }
}

.img-txt {
  display: flex;
  flex-direction: column;
  text-align: center;
  margin: 14px;
  position: relative;

  .downBtn {
    position: absolute;
    top: 10px;
    right: 0px;
    display: none;
  }

  .user-info-head {
    width: 260px;
    height: 412px;

    //border: 1px solid #000;
    .img-style {
      width: 100%;
      height: 100%;

      ::v-deep .el-image__error {
        opacity: 0;
      }
    }
  }
}

.consentBox {
  display: flex;
  flex-wrap: wrap;

  .consentBoxImage {
    width: 260px;
    height: 370px;
    margin: 14px;
  }

  .consentBoxtext {
    text-align: center;
  }
}

.uploadImageBox {
  //width: 500px;
  min-height: 500px;
  border: 1px solid #f3a4a1;
  margin: 10px auto;

  .draggable-item {
    display: inline-block;
    margin: 0 8px 8px 0;
    font-size: 0;
    line-height: 0;
    vertical-align: middle;
    position: relative;
  }
}

::v-deep .el-collapse-item__header {
  font-size: 15px;
  color: #409eff;
}

.base-info-box {
  margin: 20px 0;
  font-size: 15px;
}

.base-info-box span {
  margin-right: 15px;
}

.group-info {
  display: flex;
}

.group-info span {
  margin-right: 15px;
}

.group-info .device div {
  display: inline-block;
  vertical-align: top;
}

.flex-span {
  display: flex;
}
.yesActive {
  background-color: #409eff;
  color: #fff;
}

.center-tabs {
  min-height: 600px;
}

::v-deep .el-dialog {
  margin-top: 0 !important;
}

.min-height {
  min-height: 700px;
}

::v-deep .selectRed {
  .el-input__inner {
    border: 1px solid red;
  }
}

.bigFont {
  font-weight: bold;
  font-size: 15px;

  .normalFont {
    font-weight: normal;
  }
}
.w700 {
  width: 700px;
}
@media only screen and (max-width: 1000px) {
  .w700 {
    width: 100%;
  }
}
</style>
